package com.hzhr.iot.toll.service;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.CygQuery;
import com.hzhr.iot.core.annotation.CygQuerys;
import com.hzhr.iot.core.annotation.CygService;
import com.hzhr.iot.core.constant.AccessModeEnum;
import com.hzhr.iot.core.constant.CommonOptions;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.device.sdk.service.Device_CollectDeviceService;
import com.hzhr.iot.login.sdk.model.userCard.UserCardModel;
import com.hzhr.iot.toll.constant.Toll_ErrorsEnum;
import com.hzhr.iot.toll.convertor.custom.GasUserCustomConvertor;
import com.hzhr.iot.toll.dao.GasUserDao;
import com.hzhr.iot.toll.dao.helper.GasUserDaoHelper;
import com.hzhr.iot.toll.entity.GasUserEntity;
import com.hzhr.iot.toll.entity.ext.GasUserEntityExt;
import com.hzhr.iot.toll.model.gasUser.*;
import com.hzhr.iot.toll.queryModel.custom.GasUserCustomQueryModel;
import com.hzhr.iot.toll.service.base.BaseService;
import com.hzhr.iot.user.sdk.model.dept_name.Dept_NameModel;
import com.hzhr.iot.user.sdk.service.User_CompanyService;
import com.hzhr.iot.user.sdk.service.User_DeptService;
import com.hzhr.iot.user.sdk.service.User_Dept_NameService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@CygService(entity = GasUserEntity.class, model = GasUserModel.class)
@CygQuerys({
        @CygQuery(name = "_equal_id", query = "equal_id", type = Integer.class),
        @CygQuery(name = "_equal_code", query = "equal_code", type = String.class),
        @CygQuery(name = "_equal_companyId", query = "equal_companyId", type = Integer.class),
        @CygQuery(name = "_equal_deptId", query = "equal_deptId", type = Integer.class),
        @CygQuery(name = "_greaterthanorequal_createTime", query = "greaterthanorequal_createTime", type = Date.class),
        @CygQuery(name = "_lessthan_createTime", query = "lessthan_createTime", type = Date.class),
        @CygQuery(name = "_like_name", query = "like_name", type = String.class),
        @CygQuery(name = "_like_address", query = "like_address", type = String.class),
        @CygQuery(name = "_equal_typeCode", query = "equal_typeCode", type = String.class),

})
public class GasUserService extends BaseService {
    @Autowired
    GasUserCustomConvertor gasUserCustomConvertor;
    @Autowired
    GasUserDao gasUserDao;
    @Autowired
    GasUserService gasUserService;
    @Autowired
    User_CompanyService user_companyService;
    @Autowired
    User_DeptService user_deptService;
    @Autowired
    Device_CollectDeviceService device_collectDeviceService;
    @Autowired
    GasUserDaoHelper gasUserDaoHelper;
    @Autowired
    User_Dept_NameService user_dept_nameService;

    //region javadoc注释 : post
    /**
     * 在登录用户的管辖范围内创建燃气用户 <br/><br/>
     * 简介&nbsp;:&nbsp;在登录用户的管辖范围内创建燃气用户 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;验证燃气用户代码&nbsp;:&nbsp;(√) <br/>
     * 如果body.code&nbsp;==&nbsp;null，建立以下循环来获取code： <br/>
     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(1)&nbsp;生成10位随机数str，验证str是否合法，验证规则如下： <br/>
     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;根据str查询燃气用户(GAS_USER)对象gasUser，如果gasUser存在，则str不合法，查询筛选规则如下： <br/>
     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(1)&nbsp;gasUser.code&nbsp;=&nbsp;str； <br/>
     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(2)&nbsp;gasUser.companyId&nbsp;=&nbsp;登录用户.companyId； <br/>
     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(2)&nbsp;如果str不合法，继续步骤(1)，直到str_1合法为止，code&nbsp;=&nbsp;str； <br/>
     * 如果body.code&nbsp;!=&nbsp;null，验证body.code是否合法，验证规则如下： <br/>
     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;查询燃气用户(GAS_USER)对象gasUser，如果gasUser存在，则body.code不合法，查询筛选规则如下： <br/>
     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(1)&nbsp;gasUser.code&nbsp;=&nbsp;str； <br/>
     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(2)&nbsp;gasUser.companyId&nbsp;=&nbsp;登录用户.companyId； <br/>
     * &nbsp;如果body.code不合法，则抛出异常201; <br/>
     * 2.&nbsp;创建燃气用户&nbsp;:&nbsp;(√) <br/>
     * 根据body创建燃气用户(GAS_USER)对象gasUser_1， <br/>
     * 额外属性设置如下： <br/>
     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(1)&nbsp;gasUser_1.resourceCode&nbsp;=&nbsp;登录用户.userCode; <br/>
     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(2)&nbsp;gasUser_1.deptId&nbsp;=&nbsp;登录用户.deptId; <br/>
     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(3)&nbsp;gasUser_1.companyId&nbsp;=&nbsp;登录用户.companyId; <br/>
     * 3.&nbsp;返回模型&nbsp;:&nbsp;(√) <br/>
     * 根据请求条件参数返回创建好的燃气用户的数据模型; <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/>
     * _show : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 展示形式 one:展示一个,list:展示列表,null(空值):不展示;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _show_info : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示详情;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/><br/>
     * @param body <br/><br/>
     * @throws ServiceException <br/>
     * GASUSERSERVICE_POST_201 : <br/>&nbsp&nbsp&nbsp&nbsp异常类型 : 业务流程异常<br/>&nbsp&nbsp&nbsp&nbsp异常业务 : 燃气用户代码认证<br/>&nbsp&nbsp&nbsp&nbsp异常描述 : 用户代码已存在<br/>
     * @see GasUserPostModel body <br/>
     * @see GasUserGetModel result <br/>
     */ 
    //endregion
    //region 说明 : post
    //在登录用户的管辖范围内创建燃气用户
    //简介 : 在登录用户的管辖范围内创建燃气用户
    //步骤 :
    //1. 验证燃气用户代码 : (√)
    //如果body.code == null，建立以下循环来获取code：
    //          (1) 生成10位随机数str，验证str是否合法，验证规则如下：
    //                    根据str查询燃气用户(GAS_USER)对象gasUser，如果gasUser存在，则str不合法，查询筛选规则如下：
    //                              (1) gasUser.code = str；
    //                              (2) gasUser.companyId = 登录用户.companyId；
    //          (2) 如果str不合法，继续步骤(1)，直到str_1合法为止，code = str；
    //如果body.code != null，验证body.code是否合法，验证规则如下：
    //          查询燃气用户(GAS_USER)对象gasUser，如果gasUser存在，则body.code不合法，查询筛选规则如下：
    //                    (1) gasUser.code = str；
    //                    (2) gasUser.companyId = 登录用户.companyId；
    // 如果body.code不合法，则抛出异常201;
    //2. 创建燃气用户 : (√)
    //根据body创建燃气用户(GAS_USER)对象gasUser_1，
    //额外属性设置如下：
    //          (1) gasUser_1.resourceCode = 登录用户.userCode;
    //          (2) gasUser_1.deptId = 登录用户.deptId;
    //          (3) gasUser_1.companyId = 登录用户.companyId;
    //3. 返回模型 : (√)
    //根据请求条件参数返回创建好的燃气用户的数据模型;
    //endregion
    //region 参数 : post
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
    })
    //endregion
    //region 请求 : post
    @RequestMapping(value = "/gas-users", method = RequestMethod.POST)
    //endregion
    public GasUserGetModel post(Map<String, String> header, Map<String, Object> query,
                                GasUserPostModel body) throws ServiceException {
        UserCardModel userCard = getUserCard(header);

        /* 验证燃气用户代码 */
        String code = body.getCode();
        if (StringUtils.isEmpty(code)) {
            code = RandomUtils.nextLong(1000000000L, 9999999999L) + "";
            int existCount = gasUserDaoHelper.getCountByCodeAndCompanyId(code, userCard.getCompanyId());
            while (existCount > 0) {
                existCount = gasUserDaoHelper.getCountByCodeAndCompanyId(code, userCard.getCompanyId());
            }
            body.setCode(code);
        } else {
            int existCount = gasUserDaoHelper.getCountByCodeAndCompanyId(code, userCard.getCompanyId());
            if (existCount > 0) {
                throw new ServiceException(Toll_ErrorsEnum.GASUSERSERVICE_POST_201);
            }
        }

        /* 创建燃气用户 */
        GasUserEntity gasUserEntity = gasUserCustomConvertor.gasUserPostModel2entity(body);
        gasUserEntity.setCreateTime(new Date());
        gasUserEntity.setCreateUserId(userCard.getUserId());
        gasUserEntity.setResourceCode(userCard.getUserCode());
        gasUserEntity.setDeptId(userCard.getDeptId());
        gasUserEntity.setCompanyId(userCard.getCompanyId());
        gasUserEntity.setIsValid(CommonOptions.YES_NO.YES);
        gasUserEntity.setState("1");
        int changeCount = gasUserDao.insert(gasUserEntity);

        /* 返回模型 */
        GasUserGetModel result = gasUserService.getById(initHeader(header, AccessModeEnum.GLOBAL), gasUserEntity.getId(), query);
        result.setChangeCount(changeCount);
        return result;
    }

    //region javadoc注释 : deleteById
    /**
     * 根据燃气用户编号删除登录用户管辖范围下的燃气用户 <br/><br/>
     * 简介&nbsp;:&nbsp;根据燃气用户编号删除登录用户管辖范围下的燃气用户 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;删除燃气用户&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据路径参数gasUserId删除燃气用户(GAS_USER)对象gasUser_1， <br/>
     * &nbsp;路径参数筛选规则： <br/>
     * &nbsp;(1)&nbsp;gasUser_1.id&nbsp;=&nbsp;路径参数gasUserId; <br/>
     * 2.&nbsp;返回模型&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据删除情况返回删除模型; <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/><br/>
     * @param gasUserId 燃气用户编号 <br/><br/>
     * @throws ServiceException <br/>
     * @see GasUserDeleteModel result <br/>
     */ 
    //endregion
    //region 说明 : deleteById
    //根据燃气用户编号删除登录用户管辖范围下的燃气用户
    //简介 : 根据燃气用户编号删除登录用户管辖范围下的燃气用户
    //步骤 :
    //1. 删除燃气用户 : (√)
    // 根据路径参数gasUserId删除燃气用户(GAS_USER)对象gasUser_1，
    // 路径参数筛选规则：
    // (1) gasUser_1.id = 路径参数gasUserId;
    //2. 返回模型 : (√)
    // 根据删除情况返回删除模型;
    //endregion
    //region 参数 : deleteById
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "gasUserId", value = "燃气用户编号",required = true, dataType = "int", paramType = "path"),
    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),
    })
    //endregion
    //region 请求 : deleteById
    @RequestMapping(value = "/gas-users/{gasUserId}", method = RequestMethod.DELETE)
    //endregion
    public GasUserDeleteModel deleteById(Map<String, String> header, Integer gasUserId,
                                         Map<String, Object> query) throws ServiceException {
        UserCardModel userCard = getUserCard(header);

        /* 删除燃气用户 */
        int changeCount = gasUserDaoHelper.deleteByIdAndResourceCode(gasUserId, userCard.getUserCode(), userCard.getUserId());

        /* 返回模型 */
        GasUserDeleteModel result = new GasUserDeleteModel();
        result.setChangeCount(changeCount);
        return result;
    }

    //region javadoc注释 : putById
    /**
     * 根据燃气用户编号修改登录用户管辖范围下的燃气用户信息 <br/><br/>
     * 简介&nbsp;:&nbsp;根据燃气用户编号修改登录用户管辖范围下的燃气用户信息 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;查询燃气用户&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据请求路径参数gasUserId查询燃气用户(GAS_USER)对象gasUser_1， <br/>
     * &nbsp;路径参数筛选规则如下： <br/>
     * &nbsp;(1)&nbsp;gasUser_1.id&nbsp;=&nbsp;路径参数gasUserId； <br/>
     * &nbsp;额外筛选规则如下： <br/>
     * &nbsp;(1)&nbsp;gasUser_1.resourceCode&nbsp;like&nbsp;登录用户.userCode&nbsp;+&nbsp;'%' <br/>
     * &nbsp;如果gasUser_1不存在，抛出异常201； <br/>
     * 2.&nbsp;验证新的燃气用户代码&nbsp;:&nbsp;(√) <br/>
     * &nbsp;如果body.code&nbsp;!=&nbsp;gasUser_1.code，查询燃气用户(GAS_USER)对象gasUser_2，查询规则如下： <br/>
     * &nbsp;(1)&nbsp;gasUser_2.code&nbsp;=&nbsp;body.code； <br/>
     * &nbsp;如果gasUser_2存在，抛出异常202； <br/>
     * 3.&nbsp;更新燃气用户:&nbsp;&nbsp;(√) <br/>
     * &nbsp;根据body更新gasUser_1; <br/>
     * 4.&nbsp;返回信息&nbsp;:&nbsp;(√) <br/>
     * &nbsp;查询更新后的gasUser_1，并根据请求条件参数生成结果对象并返回; <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/>
     * _show : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 展示形式 one:展示一个,list:展示列表,null(空值):不展示;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _show_info : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示详情;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/><br/>
     * @param gasUserId 燃气用户编号 <br/><br/>
     * @param body <br/><br/>
     * @throws ServiceException <br/>
     * @see GasUserPutModel body <br/>
     * @see GasUserGetModel result <br/>
     */ 
    //endregion
    //region 说明 : putById
    //根据燃气用户编号修改登录用户管辖范围下的燃气用户信息
    //简介 : 根据燃气用户编号修改登录用户管辖范围下的燃气用户信息
    //步骤 :
    //1. 查询燃气用户 : (√)
    // 根据请求路径参数gasUserId查询燃气用户(GAS_USER)对象gasUser_1，
    // 路径参数筛选规则如下：
    // (1) gasUser_1.id = 路径参数gasUserId；
    // 额外筛选规则如下：
    // (1) gasUser_1.resourceCode like 登录用户.userCode + '%'
    // 如果gasUser_1不存在，抛出异常201；
    //2. 验证新的燃气用户代码 : (√)
    // 如果body.code != gasUser_1.code，查询燃气用户(GAS_USER)对象gasUser_2，查询规则如下：
    // (1) gasUser_2.code = body.code；
    // 如果gasUser_2存在，抛出异常202；
    //3. 更新燃气用户:  (√)
    // 根据body更新gasUser_1;
    //4. 返回信息 : (√)
    // 查询更新后的gasUser_1，并根据请求条件参数生成结果对象并返回;
    //endregion
    //region 参数 : putById
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "gasUserId", value = "燃气用户编号",required = true, dataType = "int", paramType = "path"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
    })
    //endregion
    //region 请求 : putById
    @RequestMapping(value = "/gas-users/{gasUserId}", method = RequestMethod.PUT)
    //endregion
    public GasUserGetModel putById(Map<String, String> header, Integer gasUserId,
                                         Map<String, Object> query, GasUserPutModel body) throws ServiceException {
        UserCardModel userCard = getUserCard(header);

        /* 查询燃气用户 */
        String gasUserCode = body.getCode();
        GasUserEntity gasUser_1 = gasUserDaoHelper.getByIdAndResourceCode(gasUserId, userCard.getUserCode());
        if (gasUser_1 == null) {
            throw new ServiceException(Toll_ErrorsEnum.GASUSERSERVICE_PUT_201);
        }

        /* 验证新的燃气用户代码 */
        if (!gasUserCode.equals(gasUser_1.getCode())) {
            int existCount = gasUserDaoHelper.getCountByCodeAndCompanyId(gasUserCode, userCard.getCompanyId());
            if (existCount > 0) {
                throw new ServiceException(Toll_ErrorsEnum.GASUSERSERVICE_PUT_202);
            }
        }

        /* 更新燃气用户 */
        gasUser_1.setCode(body.getCode());
        gasUser_1.setName(body.getName());
        gasUser_1.setAddress(body.getAddress());
        gasUser_1.setPhone(body.getPhone());
        gasUser_1.setTypeCode(body.getTypeCode());
        gasUser_1.setRemark(body.getRemark());
        gasUser_1.setUpdateTime(new Date());
        gasUser_1.setUpdateUserId(userCard.getUserId());
        int changeCount = gasUserDao.update(gasUser_1);

        /* 返回信息 */
        GasUserGetModel result = gasUserService.getById(
                initHeader(header, AccessModeEnum.GLOBAL), gasUser_1.getId(), query);
        result.setChangeCount(changeCount);
        return result;
    }

    //region javadoc注释 : get
    /**
     * 查询登录用户管辖范围下的燃气用户 <br/><br/>
     * 简介&nbsp;:&nbsp;查询登录用户管辖范围下的燃气用户 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;查询燃气用户&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据请求条件参数查询燃气用户(GAS_USER)对象集合gasUserList_1及总数， <br/>
     * &nbsp;额外筛选条件如下： <br/>
     * &nbsp;gasUserList_1[i].resourceCode&nbsp;=&nbsp;登录用户.userCode&nbsp;+&nbsp;'%'; <br/>
     * 2.&nbsp;返回信息&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据条件参数和gasUserList_1及总数生成结果对象result并返回， <br/>
     * &nbsp;其中GasUserModel模型的deptName属性的设置方法如下： <br/>
     * &nbsp;GLOBAL方式调用user_dept_nameService.get服务获取到Dept_NameModel模型对象进行设置，GasUserModel模型和Dept_NameModel模型的对应关系如下： <br/>
     * &nbsp;(1)&nbsp;GasUserModel模型的deptId属性对应于user-service的Dept_NameModel的id属性(一对一)； <br/>
     * &nbsp;(2)&nbsp;GasUserModel模型的deptName属性对应于user-service的Dept_NameModel的name属性； <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/>
     * _show : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 展示形式 one:展示一个,list:展示列表,null(空值):不展示;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _show_total : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示总数;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/>
     * _show_info : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示详情;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/>
     * _show_dept : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示部门信息;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/>
     * _show_gasConsume : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示用气总量;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/>
     * _page : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 页数;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 1;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _count : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 每页数量;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 1;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _equal_id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where gasUser.id = #{_equal_id};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _equal_code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where gasUser.code = #{_equal_code};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _equal_deptId : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where gasUser.deptId = #{_equal_deptId};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _equal_companyId : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where gasUser.companyId = #{_equal_companyId};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _greaterthanorequal_createTime : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where gasUser.createTime >= #{_greaterthanorequal_createTime};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : long;<br/>
     * _lessthan_createTime : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where gasUser.createTime < #{_lessthan_createTime};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : long;<br/>
     * _like_name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where gasUser.name like #{_like_name};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _like_address : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where gasUser.address like #{_like_address};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _equal_typeCode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where gasUser.typeCode = #{_equal_typeCode};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/><br/>
     * @throws ServiceException <br/>
     * @see GasUserGetModel result <br/>
     */ 
    //endregion
    //region 说明 : get
    //查询登录用户管辖范围下的燃气用户
    //简介 : 查询登录用户管辖范围下的燃气用户
    //步骤 :
    //1. 查询燃气用户 : (√)
    // 根据请求条件参数查询燃气用户(GAS_USER)对象集合gasUserList_1及总数，
    // 额外筛选条件如下：
    // gasUserList_1[i].resourceCode = 登录用户.userCode + '%';
    //2. 返回信息 : (√)
    // 根据条件参数和gasUserList_1及总数生成结果对象result并返回，
    // 其中GasUserModel模型的deptName属性的设置方法如下：
    // GLOBAL方式调用user_dept_nameService.get服务获取到Dept_NameModel模型对象进行设置，GasUserModel模型和Dept_NameModel模型的对应关系如下：
    // (1) GasUserModel模型的deptId属性对应于user-service的Dept_NameModel的id属性(一对一)；
    // (2) GasUserModel模型的deptName属性对应于user-service的Dept_NameModel的name属性；
    //endregion
    //region 参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_dept", value = "是否展示部门信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_gasConsume", value = "是否展示用气总量", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where gasUser.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_code", value = "筛选条件 : where gasUser.code = #{equal_code}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "equal_deptId", value = "筛选条件 : where gasUser.deptId = #{equal_deptId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_companyId", value = "筛选条件 : where gasUser.companyId = #{equal_companyId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "greaterthanorequal_createTime", value = "筛选条件 : where gasUser.createTime >= #{greaterthanorequal_createTime}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "lessthan_createTime", value = "筛选条件 : where gasUser.createTime < #{lessthan_createTime}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "like_name", value = "筛选条件 : where gasUser.name like #{like_name}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "like_address", value = "筛选条件 : where gasUser.address like #{like_address}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "equal_typeCode", value = "筛选条件 : where gasUser.typeCode = #{equal_typeCode}",required = false, dataType = "string", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_dept", value = "是否展示部门信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_gasConsume", value = "是否展示用气总量", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where gasUser.id = #{_equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_code", value = "筛选条件 : where gasUser.code = #{_equal_code}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_equal_deptId", value = "筛选条件 : where gasUser.deptId = #{_equal_deptId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_companyId", value = "筛选条件 : where gasUser.companyId = #{_equal_companyId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthanorequal_createTime", value = "筛选条件 : where gasUser.createTime >= #{_greaterthanorequal_createTime}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "_lessthan_createTime", value = "筛选条件 : where gasUser.createTime < #{_lessthan_createTime}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "_like_name", value = "筛选条件 : where gasUser.name like #{_like_name}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_like_address", value = "筛选条件 : where gasUser.address like #{_like_address}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_equal_typeCode", value = "筛选条件 : where gasUser.typeCode = #{_equal_typeCode}",required = false, dataType = "string", paramType = "query"),

    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/gas-users", method = RequestMethod.GET)
    //endregion
    public GasUserGetModel get(Map<String, String> header, Map<String, Object> query) throws ServiceException {
        String loginUserUserCode = getUserCode(header);

        /* 查询燃气用户 */
        //组装查询模型
        GasUserCustomQueryModel queryModel = gasUserCustomConvertor.gasUserService_query2queryModel(query);
        queryModel.setLike_resourceCode(loginUserUserCode + "%");
        queryModel.setEqual_isValid(CommonOptions.YES_NO.YES);
        //查询实体
        List<GasUserEntityExt> extList = null;
        String show = HzhrTypeUtil.object2string(query.get("_show"));
        if (!StringUtils.isEmpty(show)) {
            extList = gasUserDao.selectExtList(queryModel);
        }
        //查询数量
        Integer total = null;
        Boolean showTotal = HzhrTypeUtil.object2boolean(query.get("_show_total"));
        if (showTotal != null && showTotal) {
            total = gasUserDao.selectCount(queryModel);
        }

        /* 返回模型 */
        GasUserGetModel result = gasUserCustomConvertor.extList2gasUserGetModel(extList, total, null, query);
        GasUserModel model = result.getModel();
        if (model != null) {
            Map<String, Object> query1 = new HashMap<>();
            query1.put("_equal_id", model.getDeptId());
            query1.put("_show", "one");
            query1.put("_show_info", true);
            Dept_NameModel dept_nameModel  = user_dept_nameService.get(initHeader(header, AccessModeEnum.GLOBAL), query1).getModel();
            if (dept_nameModel != null) {
                model.setDeptName(dept_nameModel.getName());
            }
        }
        List<GasUserModel> modelList = result.getModelList();
        if (modelList != null) {
            for (GasUserModel model1 :
                    modelList) {
                Map<String, Object> query1 = new HashMap<>();
                query1.put("_equal_id", model1.getDeptId());
                query1.put("_show", "one");
                query1.put("_show_info", true);
                Dept_NameModel dept_nameModel  = user_dept_nameService.get(initHeader(header, AccessModeEnum.GLOBAL), query1).getModel();
                if (dept_nameModel != null) {
                    model1.setDeptName(dept_nameModel.getName());
                }
            }
        }
        return result;
    }

    //region javadoc注释 : getById
    /**
     * 根据燃气用户编号查询燃气用户 <br/><br/>
     * 简介&nbsp;:&nbsp;查根据燃气用户编号询燃气用户 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;查询燃气用户&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据请求条件参数和路径参数gasUserId查询燃气用户(GAS_USER)对象gasUser_1， <br/>
     * &nbsp;路径参数筛选规则如下： <br/>
     * &nbsp;gasUser_1.id&nbsp;=&nbsp;路径参数gasUserId; <br/>
     * 2.&nbsp;返回信息&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据gasUser_1和条件参数生成结果对象result并返回， <br/>
     * &nbsp;其中GasUserModel模型的deptName属性的设置方法如下： <br/>
     * &nbsp;GLOBAL方式调用user_dept_nameService.get服务获取到Dept_NameModel模型对象进行设置，GasUserModel模型和Dept_NameModel模型的对应关系如下： <br/>
     * &nbsp;(1)&nbsp;GasUserModel模型的deptId属性对应于user-service的Dept_NameModel的id属性(一对一)； <br/>
     * &nbsp;(2)&nbsp;GasUserModel模型的deptName属性对应于user-service的Dept_NameModel的name属性； <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/>
     * _show : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 展示形式 one:展示一个,list:展示列表,null(空值):不展示;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _show_total : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示总数;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/>
     * _show_info : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示详情;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/>
     * _show_dept : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示部门信息;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/>
     * _show_gasConsume : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示用气总量;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/><br/>
     * @throws ServiceException <br/>
     * @see GasUserGetModel result <br/>
     */ 
    //endregion
    //region 说明 : getById
    //根据燃气用户编号查询燃气用户
    //简介 : 查根据燃气用户编号询燃气用户
    //步骤 :
    //1. 查询燃气用户 : (√)
    // 根据请求条件参数和路径参数gasUserId查询燃气用户(GAS_USER)对象gasUser_1，
    // 路径参数筛选规则如下：
    // gasUser_1.id = 路径参数gasUserId;
    //2. 返回信息 : (√)
    // 根据gasUser_1和条件参数生成结果对象result并返回，
    // 其中GasUserModel模型的deptName属性的设置方法如下：
    // GLOBAL方式调用user_dept_nameService.get服务获取到Dept_NameModel模型对象进行设置，GasUserModel模型和Dept_NameModel模型的对应关系如下：
    // (1) GasUserModel模型的deptId属性对应于user-service的Dept_NameModel的id属性(一对一)；
    // (2) GasUserModel模型的deptName属性对应于user-service的Dept_NameModel的name属性；
    //endregion
    //region 参数 : getById
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_dept", value = "是否展示部门信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_gasConsume", value = "是否展示用气总量", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_dept", value = "是否展示部门信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_gasConsume", value = "是否展示用气总量", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    //endregion
    //region 请求 : getById
    @RequestMapping(value = "/gas-users/{gasUserId}", method = RequestMethod.GET)
    //endregion
    public GasUserGetModel getById(Map<String, String> header, Integer gasUserId,
                                       Map<String, Object> query) throws ServiceException {
        /* 查询燃气用户 */
        //组装查询模型
        GasUserCustomQueryModel queryModel = gasUserCustomConvertor.gasUserService_query2queryModel(query);
        queryModel.setEqual_id(gasUserId);
        queryModel.setEqual_isValid(CommonOptions.YES_NO.YES);
        //查询实体
        List<GasUserEntityExt> extList = null;
        String show = HzhrTypeUtil.object2string(query.get("_show"));
        if (!StringUtils.isEmpty(show)) {
            extList = gasUserDao.selectExtList(queryModel);
        }

        /* 返回信息 */
        GasUserGetModel result = gasUserCustomConvertor.extList2gasUserGetModel(
                extList, extList != null ? extList.size() : 0, null, query);
        GasUserModel model = result.getModel();
        if (model != null) {
            Map<String, Object> query1 = new HashMap<>();
            query1.put("_equal_id", model.getDeptId());
            query1.put("_show", "one");
            query1.put("_show_info", true);
            Dept_NameModel dept_nameModel  = user_dept_nameService.get(initHeader(header, AccessModeEnum.GLOBAL), query1).getModel();
            if (dept_nameModel != null) {
                model.setDeptName(dept_nameModel.getName());
            }
        }
        List<GasUserModel> modelList = result.getModelList();
        if (modelList != null) {
            for (GasUserModel model1 :
            modelList) {
                Map<String, Object> query1 = new HashMap<>();
                query1.put("_equal_id", model1.getDeptId());
                query1.put("_show", "one");
                query1.put("_show_info", true);
                Dept_NameModel dept_nameModel  = user_dept_nameService.get(initHeader(header, AccessModeEnum.GLOBAL), query1).getModel();
                if (dept_nameModel != null) {
                    model1.setDeptName(dept_nameModel.getName());
                }
            }
        }
        return result;
    }

}










































































































































































































































































































